package lj.netty.bean;

import io.netty.channel.Channel;
import lombok.Data;

/**
 * netty 消息实体
 */
@Data
public class LJNettyBo {

    /** 标识 */
    private String nettyCode;

    /** 消息体 */
    private byte[] bytes;

    /** 客户端ip */
    private String ip;

    public static LJNettyBo transform(Channel channel) {
        LJNettyBo LJNettyBo = new LJNettyBo();
        LJNettyBo.setNettyCode(channel.id().asLongText());
        LJNettyBo.setIp(channel.remoteAddress().toString());
        return LJNettyBo;
    }

    public LJNettyBo merge(Channel channel) {
        LJNettyBo LJNettyBo = new LJNettyBo();
        LJNettyBo.setNettyCode(channel.id().asLongText());
        LJNettyBo.setIp(channel.remoteAddress().toString());
        return LJNettyBo;
    }
}
